package org.demo;

import org.apache.log4j.Logger;

public class Do4log{
	
	final static Logger logger = Logger.getLogger(Do4log.class);
	
	public static void main(String[] args) {
	
		Do4log obj = new Do4log();
		Logger root=Logger.getRootLogger();
		   root.debug("Message 1");
		   root.warn("Message 2");
		obj.runMe("mkyong");
		
	}
	
	private void runMe(String parameter){
		
		if(logger.isDebugEnabled()){
			logger.debug("This is debug : " + parameter);
		}
		
		if(logger.isInfoEnabled()){
			logger.info("This is info : " + parameter);
		}
		// 有没有 logger.isInfoEnabled 判断效果一致
		logger.info("This is info : " + parameter);
		
		
		logger.trace("This is trace : " + parameter);
		logger.warn("This is warn : " + parameter);
		logger.error("This is error : " + parameter);
		logger.fatal("This is fatal : " + parameter);
		try{
			int aa=1/0;
		}catch(ArithmeticException ex){
			logger.error("Sorry, something wrong!", ex);
		}
		
	}
	
}